package com.czy.booktest02.demos.api.v1;

import com.czy.booktest02.demos.common.dtos.ResponseResult;
import com.czy.booktest02.demos.pojo.dto.UserDto;
import com.czy.booktest02.demos.pojo.dto.UserLoginDto;
import com.czy.booktest02.demos.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/loading")
public class LoginController {

    @Autowired
    UserService userService;

    @PostMapping("/login")
    public ResponseResult login(@Valid @RequestBody UserLoginDto userDto){
        return userService.login(userDto);
    }


    @PostMapping("/register")
    public ResponseResult register(@Valid @RequestBody UserDto userDto ){
        return userService.register(userDto);
    }
}
